package com.work.api.main;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.work.dto.main.ShipBillStorageSearchDTO;
import com.work.dto.transport.TransportSearchDTO;
import com.work.entity.main.ShipBillStorage;
import com.work.entity.main.TShipBillStatus;
import com.work.service.main.IShipBillStorageService;
import com.work.vo.main.*;
import com.work.vo.transport.TransportShipVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * 场存控制器
 *
 * @author ：dujianyu
 * @since ：Created in 2024/3/14 10:44
 */
@RestController
@AllArgsConstructor
@RequestMapping("shipBillStorage")
@Api(value = "场存控制器", tags = "场存控制器")
public class ShipBillStorageController extends BladeController {

    private IShipBillStorageService service;

    @GetMapping("getStorageByTransportBillId")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "根据货运舱单ID获取库存 ", notes = "传入DTO")
    public R<PieceTonVO> getStorageByTransportBillId(ShipBillStorageSearchDTO dto) {
        return R.data(service.getStorageByTransportBillId(dto));
    }

    @GetMapping("getStorageDetail")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "根据货运舱单ID获取库存 ", notes = "传入DTO")
    public R<ShipBillStorageVO> getStorageDetail(ShipBillStorageSearchDTO dto) {
        return R.data(service.getStorageDetail(dto));
    }

    @GetMapping("shipBillStoragePage")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "场存分页", notes = "传入DTO")
    public R<IPage<ShipBillStorageVO>> selectShipBillStoragePage(ShipBillStorageSearchDTO dto, Query query) {
        return R.data(service.selectShipBillStoragePage(Condition.getPage(query), dto));
    }

    @GetMapping("shipBillStorageTotal")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "场存合计", notes = "传入DTO")
    public R<PieceTonVO> selectShipBillStorageTotal(ShipBillStorageSearchDTO dto) {
        return R.data(service.selectShipBillStorageTotal(dto));
    }

    @GetMapping("shipBillStorageList")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "场存列表", notes = "传入DTO")
    public R<List<ShipBillStorageVO>> selectShipBillStorageList(ShipBillStorageSearchDTO dto) {
        return R.data(service.selectShipBillStorageList(dto));
    }

    @PostMapping("/clearStorage")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "清空货垛", notes = "传入主键ID")
    public R<Boolean> clearStorage(@RequestParam String transportBillId) {
        return R.status(service.clearStorage(transportBillId));
    }

    @GetMapping("storageByPositionPage")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "货物库存汇总统计-货场", notes = "传入DTO")
    public R<IPage<StorageByPositionVO>> selectStorageByPositionPage(ShipBillStorageSearchDTO dto, Query query) {
        return R.data(service.selectStorageByPositionPage(Condition.getPage(query), dto));
    }

    @GetMapping("storageByPositionTotal")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "货物库存汇总统计-货场统计", notes = "传入DTO")
    public R<PieceTonVO> selectStorageByPositionTotal(ShipBillStorageSearchDTO dto) {
        return R.data(service.selectStorageByPositionTotal(dto));
    }

    @GetMapping("storageByPositionDetailPage")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "货物库存汇总统计-货场详情", notes = "传入DTO")
    public R<IPage<StorageByPositionDetailVO>> selectStorageByPositionDetailPage(ShipBillStorageSearchDTO dto, Query query) {
        return R.data(service.selectStorageByPositionDetailPage(Condition.getPage(query), dto));
    }


    @GetMapping("storageByPositionTallyPage")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "货物库存汇总统计-货场理货", notes = "传入DTO")
    public R<IPage<StorageByPositionTallyVO>> selectStorageByPositionTallyPage(ShipBillStorageSearchDTO dto, Query query) {
        return R.data(service.selectStorageByPositionTallyPage(Condition.getPage(query), dto));
    }

    @GetMapping("storageByCargoPage")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "货物库存汇总统计-货名", notes = "传入DTO")
    public R<IPage<StorageByCargoVO>> selectStorageByCargoPage(ShipBillStorageSearchDTO dto, Query query) {
        return R.data(service.selectStorageByCargoPage(Condition.getPage(query), dto));
    }


    @GetMapping("storageByCargoDetailPage")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "货物库存汇总统计-货名详情", notes = "传入DTO")
    public R<IPage<StorageByCargoDetailVO>> selectStorageByCargoDetailPage(ShipBillStorageSearchDTO dto, Query query) {
        return R.data(service.selectStorageByCargoDetailPage(Condition.getPage(query), dto));
    }

    @GetMapping("storageByCargoTotal")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "货物库存汇总统计-货名统计", notes = "传入DTO")
    public R<PieceTonVO> selectStorageByCargoTotal(ShipBillStorageSearchDTO dto) {
        return R.data(service.selectStorageByCargoTotal(dto));
    }

    @GetMapping("storageByShipPage")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "货物库存汇总统计-船名", notes = "传入DTO")
    public R<IPage<StorageByShipVO>> selectStorageByShipPage(ShipBillStorageSearchDTO dto, Query query) {
        return R.data(service.selectStorageByShipPage(Condition.getPage(query), dto));
    }

    @GetMapping("storageByShipTotal")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "货物库存汇总统计-船名统计", notes = "传入DTO")
    public R<PieceTonVO> selectStorageByShipTotal(ShipBillStorageSearchDTO dto) {
        return R.data(service.selectStorageByShipTotal(dto));
    }

    @GetMapping("storageByShipDetailPage")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "货物库存汇总统计-船名详情", notes = "传入DTO")
    public R<IPage<StorageByShipDetailVO>> selectStorageByShipDetailPage(ShipBillStorageSearchDTO dto, Query query) {
        return R.data(service.selectStorageByShipDetailPage(Condition.getPage(query), dto));
    }


}
